package BC119_小乐乐与字符串;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();

        long c = 0, h = 0, n = 0;
        for(int i = 0;i < str.length(); i++)
        {
            if(str.charAt(i) == 'C') {
                c++;
            }
            else if(str.charAt(i) == 'H') {
                h += c;
            }
            else if(str.charAt(i) == 'N') {
                n += h;
            }
        }
        System.out.println(n);
    }

}